<template>
	<view>
		<view class="content" >
			<view class="dati1">
				<image id="dati2" src="../../static/hm.png" mode=""></image>
				<view id="lj2">怀孕辛苦啦！体验一下孕妈妈的情节游戏，来放松一下吧！</view>
				<button  @click="fristGameJump" class="button2"><text class="ks">体验1</text></button>
			</view>
			<view class="dati2">
				<image id="dati3" src="../../static/baby.png" mode=""></image>
				<view id="lj3">恭喜当妈妈啦！这是专门为宝妈准备的情节体验哦~</view>
				<button  @click="lastGameJump" class="button3"><text class="ks">体验2</text></button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {	
				wh:0,
			}
		},
		methods: {
			...mapMutations('m_user', ['updateToken']),
			answer(){
				if (uni.getStorageSync('token') !== '') {
					uni.request({
						//api地址
						url: 'https://anmti.cn/canlogin/sinInTimes',
						//设置请求类型等于外部传入类型
						method: 'get',
						//配置请求头信息
						header: {
							"Cookie": "JSESSIONID=" + uni.getStorageSync('token').JseSsionId,
						},
						//请求成功
						success: (res) => {
							console.log(res);
							if (res.statusCode !== 200) return uni.$showMsg()
							if (res.data === 'nologin,canlogin') {
								this.updateToken('')
								uni.switchTab({
									url: "../../pages/my/my"
								})
								return uni.showToast({
									title: '请重新登录！',
									icon: 'none',
									duration: 2000,
								})
							}
						},
						//请求失败
						fail: (err) => {
							console.log(err);
						},
					})
				} else {
					uni.switchTab({
						url: "../../pages/my/my"
					})
					return uni.showToast({
						title: '请登录！',
						icon: 'none',
						duration: 2000,
					})
				}
				this.getifData()
		
			},
			fristGameJump(){
				uni.navigateTo({
					url:'./games_one/games_one',
					animationType:'fade-in',
					animationDuration:1000,
				})
			},
			lastGameJump(){
				uni.navigateTo({
					url:'./games_two/games_two',
					animationType:'fade-in',
					animationDuration:1000,
				})
			},
			// 判断是否还能答题
			getifData: function() {
				return new Promise((resolve, reject) => {
					uni.request({
						url: 'https://anmti.cn/canlogin/getQuestionDate',
						method: 'GET',
						header: {
							"Cookie": "JSESSIONID=" + uni.getStorageSync('token').JseSsionId,
						},
						success: (res) => {
							if (!res.data) {
								return uni.showToast({
									title: '今日你已完成答题，请明天再来哟！',
									icon: 'none',
									duration: 2000,
								})
							}
							else{
								uni.navigateTo({
									url:'../../subpkg/questionnaire/questionnaire',
								})
							}
							resolve('suc');
						},
						fail: (err) => {
							reject('err');
						}
					})
			
				})
			},
		},
		onLoad(){
			const sysInfo=uni.getSystemInfoSync()
			this.wh=sysInfo.windowHeight
		}
	}
</script>

<style>
	*{
		padding: 0;
		margin: 0;
	}
	#dati2{
		width: 140rpx;
		height: 140rpx;
		position: relative;
		top: 76rpx;
		left: 40rpx;
	}
	#dati3{
		width: 140rpx;
		height: 140rpx;
		position: relative;
		top: 40rpx;
		left: 40rpx;
	}
	#lj2{
		width: 400rpx;
		/* border: 1px solid red; */
		font-size: 26rpx;
		position: relative;
		left: 200rpx;
		top: -40rpx;
	}
	#lj3{
		width: 400rpx;
		/* border: 1px solid red; */
		font-size: 26rpx;
		position: relative;
		left: 200rpx;
		top: -40rpx;
	}
	.button2{
		position: relative;
		width: 140rpx;
		height:80rpx;
		margin: 0rpx 40rpx 80rpx 40rpx;
		/* top:-20rpx; */
		left: 400rpx;
		background-color:#63B8FF;
		border-radius: 20rpx;
		color: white;
	}
	.button3{
		position: relative;
		width: 140rpx;
		height:80rpx;
		margin: 0rpx 40rpx 80rpx 40rpx;
		/* top:-5rpx; */
		left: 400rpx;
		background-color:#CD853F;
		border-radius: 20rpx;
		color: white;
	}
	.ks{
		font-size: 30rpx;
		display: flex;
		justify-content: center;
	}
	.content{
		padding-top: 60rpx;
		background: url('http://r.photo.store.qq.com/psc?/V10oAX800ltCLc/ruAMsa53pVQWN7FLK88i5lKToN3C*0YbBBm1Jg3rds*yCL4r93F1IzJfkBSgVrJ4AgGAYqo4.rCVN*QF1Jahn.tjTSAWH3jwG7F8altEd0c!/r');
		background-size: 100% 100%;
		height:1200rpx;
	}
	.dati1{
		position: relative;
		top: 200rpx;
		left: 80rpx;
		width: 600rpx;
		height: 300rpx;
		/* background-color: rgba(255,255,255,0.6); */
		border-radius: 40rpx;
		margin-bottom: 60rpx;
		background: url('http://r.photo.store.qq.com/psc?/V10oAX800ltCLc/ruAMsa53pVQWN7FLK88i5taqqCF013wsAS8UJcUnObdCTMQr9XWj1z9R9.9gXktac.4.iB8p3duth58aA*QnC6MxWY.nsjwRUvwqbqjtbQU!/r');
		background-size: 100% 100%;
	}
	.dati2{
		position: relative;
		top: 200rpx;
		left: 80rpx;
		width: 600rpx;
		height: 300rpx;
		/* background-color: rgba(255,255,255,0.6); */
		border-radius: 40rpx;
		margin-bottom: 60rpx;
		background: url('http://r.photo.store.qq.com/psc?/V10oAX800ltCLc/ruAMsa53pVQWN7FLK88i5tr4dk*3XQK8OkJsh0PA.wnt1VZnt6AQEjfU9vOMkADeXSL8UoXyKTr1GJFN7.IVPHfjFYrxR*.FU.RTYD5L*9k!/r');
		background-size: 100% 100%;
	}
</style>
